package com.jswlw.controller.api;

import com.jswlw.common.BaseApiResponse;
import com.jswlw.controller.api.req.user.BindDevRequest;
import com.jswlw.controller.api.resp.*;
import com.jswlw.controller.api.wrapper.UserWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@Api(tags = "用户管理")
@RestController
@RequestMapping("/api/user")
public class ApiUserController {

    @Autowired
    UserWrapper wrapper;

    @ApiOperation(value = "用户信息", notes = "用户信息")
    @ApiResponse(code = 200, message = "OK", response = UserInfoResponse.class)
    @GetMapping("userInfo/{devId}")
    public UserInfoResponse userInfo(@PathVariable("devId") String devId) {

        return wrapper.userInfo(devId);
    }

    @ApiOperation(value = "用户设备列表", notes = "用户设备列表")
    @ApiResponse(code = 200, message = "OK", response = UserInfoResponse.class)
    @GetMapping("userDevInfoList")
    public UserDevInfoListResponse userDevInfoList() {
        return wrapper.userDevInfoList();
    }

    @ApiOperation(value = "绑定用户设备", notes = "绑定用户设备")
    @ApiResponse(code = 200, message = "OK", response = BaseApiResponse.class)
    @PostMapping("bindDev")
    public BaseApiResponse bindDev(@RequestBody BindDevRequest request) {

        return wrapper.bindDev(request);
    }

    @ApiOperation(value = "设备详情", notes = "设备详情")
    @ApiResponse(code = 200, message = "OK", response = DevInfoResponse.class)
    @GetMapping("devInfo/{devId}")
    public DevInfoResponse devInfo(@PathVariable("devId") String devId) {

        return wrapper.devInfo(devId);
    }

    @ApiOperation(value = "滤芯详情", notes = "滤芯详情")
    @ApiResponse(code = 200, message = "OK", response = DevFilterResponse.class)
    @GetMapping("devFilter/{devId}")
    public DevFilterResponse devFilter(@PathVariable("devId") String devId) {

        return wrapper.devFilter(devId);
    }

    @ApiOperation(value = "关机", notes = "关机")
    @ApiResponse(code = 200, message = "OK", response = BaseApiResponse.class)
    @GetMapping("stop/{devId}")
    public BaseApiResponse stop(@PathVariable("devId") String devId) {

        return wrapper.stop(devId);
    }

    @ApiOperation(value = "强冲", notes = "强冲")
    @ApiResponse(code = 200, message = "OK", response = BaseApiResponse.class)
    @GetMapping("force/{devId}")
    public BaseApiResponse force(@PathVariable("devId") String devId) {

        return wrapper.force(devId);
    }

    @ApiOperation(value = "开机", notes = "开机")
    @ApiResponse(code = 200, message = "OK", response = BaseApiResponse.class)
    @GetMapping("start/{devId}")
    public BaseApiResponse start(@PathVariable("devId") String devId) {

        return wrapper.start(devId);
    }

    @ApiOperation(value = "经销商信息", notes = "经销商信息")
    @ApiResponse(code = 200, message = "OK", response = DistributorResponse.class)
    @GetMapping("distributor/{devId}")
    public DistributorResponse distributor(@PathVariable("devId") String devId) {

        return wrapper.distributor(devId);
    }

    @ApiOperation(value = "用水信息", notes = "用水信息")
    @ApiResponse(code = 200, message = "OK", response = WaterInfoResponse.class)
    @GetMapping("waterInfo/{devId}")
    public WaterInfoResponse waterInfo(@PathVariable("devId") String devId) {

        return wrapper.waterInfo(devId);
    }

    @ApiOperation(value = "滤芯初始化", notes = "滤芯初始化")
    @ApiResponse(code = 200, message = "OK", response = BaseApiResponse.class)
    @GetMapping("filterInit")
    public BaseApiResponse filterInit(@PathVariable("devId") String devId,
                                      @PathVariable("filterId") Integer filterId
    ) {
        return wrapper.filterInit(devId, filterId);
    }
}
